home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60src.lha / Vim / vim60 / src / ascii.h next >
Encoding:
C/C++ Source or Header  |  2001-09-05  |  5.0 KB  |  202 lines

  1. /* vi:set ts=8 sts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved    by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  */
  8.  
  9. /*
  10.  * Definitions of various common control characters.
  11.  * For EBCDIC we have to use different values.
  12.  */
  13.  
  14. #ifndef EBCDIC
  15.  
  16. /* IF_EB(ASCII_constant, EBCDIC_constant) */
  17. #define IF_EB(a, b)    a
  18.  
  19. #define CharOrd(x)    ((x) < 'a' ? (x) - 'A' : (x) - 'a')
  20. #define CharOrdLow(x)    ((x) - 'a')
  21. #define CharOrdUp(x)    ((x) - 'A')
  22. #define ROT13(c, a)    (((((c) - (a)) + 13) % 26) + (a))
  23.  
  24. #define NUL        '\000'
  25. #define BELL        '\007'
  26. #define BS        '\010'
  27. #define TAB        '\011'
  28. #define NL        '\012'
  29. #define NL_STR        (char_u *)"\012"
  30. #define FF        '\014'
  31. #define CR        '\015'
  32. #define ESC        '\033'
  33. #define ESC_STR        (char_u *)"\033"
  34. #define ESC_STR_nc    "\033"
  35. #define DEL        0x7f
  36. #define DEL_STR        (char_u *)"\177"
  37. #define CSI        0x9b    /* Control Sequence Introducer */
  38. #define CSI_STR        "\233"
  39. #define DCS        0x90    /* Device Control String */
  40. #define STERM        0x9c    /* String Terminator */
  41.  
  42. #define POUND        0xA3
  43.  
  44. #define Ctrl_chr(x)    (TO_UPPER(x) ^ 0x40) /* '?' -> DEL, '@' -> ^@, etc. */
  45. #define Meta(x)        ((x) | 0x80)
  46.  
  47. #define CTRL_F_STR    "\006"
  48. #define CTRL_H_STR    "\010"
  49. #define CTRL_V_STR    "\026"
  50. #define CTRL_W_STR    "\027"
  51.  
  52. #define Ctrl_AT        0   /* @ */
  53. #define Ctrl_A        1
  54. #define Ctrl_B        2
  55. #define Ctrl_C        3
  56. #define Ctrl_D        4
  57. #define Ctrl_E        5
  58. #define Ctrl_F        6
  59. #define Ctrl_G        7
  60. #define Ctrl_H        8
  61. #define Ctrl_I        9
  62. #define Ctrl_J        10
  63. #define Ctrl_K        11
  64. #define Ctrl_L        12
  65. #define Ctrl_M        13
  66. #define Ctrl_N        14
  67. #define Ctrl_O        15
  68. #define Ctrl_P        16
  69. #define Ctrl_Q        17
  70. #define Ctrl_R        18
  71. #define Ctrl_S        19
  72. #define Ctrl_T        20
  73. #define Ctrl_U        21
  74. #define Ctrl_V        22
  75. #define Ctrl_W        23
  76. #define Ctrl_X        24
  77. #define Ctrl_Y        25
  78. #define Ctrl_Z        26
  79. #define Ctrl_LSB    27  /* [ Left Square Bracket */
  80. #define Ctrl_BSL    28  /* \ BackSLash */
  81. #define Ctrl_RSB    29  /* ] Right Square Bracket */
  82. #define Ctrl_HAT    30  /* ^ */
  83. #define Ctrl__        31
  84.  
  85. #else
  86.  
  87. /* EBCDIC */
  88.  
  89. /* IF_EB(ASCII_constant, EBCDIC_constant) */
  90. #define IF_EB(a, b)    b
  91.  
  92. /*
  93.  * Finding the position in the alphabet is not straightforward in EBCDIC.
  94.  * There are gaps in the code table.
  95.  * 'a' + 1 == 'b', but: 'i' + 7 == 'j' and 'r' + 8 == 's'
  96.  */
  97. #define CharOrd__(c) ((c) < ('j' - 'a') ? (c) : ((c) < ('s' - 'a') ? (c) - 7 : (c) - 7 - 8))
  98. #define CharOrdLow(x) (CharOrd__((x) - 'a'))
  99. #define CharOrdUp(x) (CharOrd__((x) - 'A'))
  100. #define CharOrd(x) (isupper(x) ? CharOrdUp(x) : CharOrdLow(x))
  101.  
  102. #define EBCDIC_CHAR_ADD_(x) ((x) < 0?'a':(x)>25?'z':"abcdefghijklmnopqrstuvwxyz"[x])
  103. #define EBCDIC_CHAR_ADD(c,s) (isupper(c) ? toupper(EBCDIC_CHAR_ADD_(CharOrdUp(c)+(s))) : EBCDIC_CHAR_ADD_(CharOrdLow(c)+(s)))
  104.  
  105. #define R13_(c) ("abcdefghijklmnopqrstuvwxyz"[((c) + 13) % 26])
  106. #define ROT13(c, a)  (isupper(c) ? toupper(R13_(CharOrdUp(c))) : R13_(CharOrdLow(c)))
  107.  
  108. #define NUL        '\000'
  109. #define BELL        '\x2f'
  110. #define BS        '\x16'
  111. #define TAB        '\x05'
  112. #define NL        '\x15'
  113. #define NL_STR        (char_u *)"\x15"
  114. #define FF        '\x0C'
  115. #define CR        '\x0D'
  116. #define ESC        '\x27'
  117. #define ESC_STR        (char_u *)"\x27"
  118. #define ESC_STR_nc    "\x27"
  119. #define DEL        0x07
  120. #define DEL_STR        (char_u *)"\007"
  121. /* TODO: EBCDIC Code page dependent (here 1047) */
  122. #define CSI        0x9b    /* Control Sequence Introducer */
  123. #define CSI_STR        "\233"
  124. #define DCS        0x90    /* Device Control String */
  125. #define STERM        0x9c    /* String Terminator */
  126.  
  127. #define POUND        '£'
  128.  
  129. #define CTRL_F_STR    "\056"
  130. #define CTRL_H_STR    "\026"
  131. #define CTRL_V_STR    "\062"
  132. #define CTRL_W_STR    "\046"
  133.  
  134. #define Ctrl_AT        0x00   /* @ */
  135. #define Ctrl_A        0x01
  136. #define Ctrl_B        0x02
  137. #define Ctrl_C        0x03
  138. #define Ctrl_D        0x37
  139. #define Ctrl_E        0x2D
  140. #define Ctrl_F        0x2E
  141. #define Ctrl_G        0x2F
  142. #define Ctrl_H        0x16
  143. #define Ctrl_I        0x05
  144. #define Ctrl_J        0x15
  145. #define Ctrl_K        0x0B
  146. #define Ctrl_L        0x0C
  147. #define Ctrl_M        0x0D
  148. #define Ctrl_N        0x0E
  149. #define Ctrl_O        0x0F
  150. #define Ctrl_P        0x10
  151. #define Ctrl_Q        0x11
  152. #define Ctrl_R        0x12
  153. #define Ctrl_S        0x13
  154. #define Ctrl_T        0x3C
  155. #define Ctrl_U        0x3D
  156. #define Ctrl_V        0x32
  157. #define Ctrl_W        0x26
  158. #define Ctrl_X        0x18
  159. #define Ctrl_Y        0x19
  160. #define Ctrl_Z        0x3F
  161. #define Ctrl_LSB    0x27  /* [ Left Square Bracket */
  162. #define Ctrl_RSB    0x1D  /* ] Right Square Bracket */
  163. #define Ctrl_BSL    0x1C  /* \ BackSLash */
  164. #define Ctrl_HAT    0x1E  /* ^ */
  165. #define Ctrl__        0x1F
  166.  
  167. #define Ctrl_chr(x)    (CtrlTable[(x)])
  168. extern char CtrlTable[];
  169.  
  170. #define CtrlChar(x)    ((x < ' ') ? CtrlCharTable[(x)] : 0)
  171. extern char CtrlCharTable[];
  172.  
  173. #define MetaChar(x)    ((x < ' ') ? MetaCharTable[(x)] : 0)
  174. extern char MetaCharTable[];
  175.  
  176. #endif /* defined EBCDIC */
  177.  
  178. /*
  179.  * Character that separates dir names in a path.
  180.  * For MS-DOS, WIN32 and OS/2 we use a backslash.  A slash mostly works
  181.  * fine, but there are places where it doesn't (e.g. in a command name).
  182.  * For Macintosh we use a colon.
  183.  * For Acorn we use a dot.
  184.  */
  185. #ifdef BACKSLASH_IN_FILENAME
  186. # define PATHSEP    psepc
  187. # define PATHSEPSTR    pseps
  188. #else
  189. # ifdef COLON_AS_PATHSEP
  190. #  define PATHSEP    ':'
  191. #  define PATHSEPSTR    ":"
  192. # else
  193. #  ifdef RISCOS
  194. #   define PATHSEP    '.'
  195. #   define PATHSEPSTR    "."
  196. #  else
  197. #   define PATHSEP    '/'
  198. #   define PATHSEPSTR    "/"
  199. #  endif
  200. # endif
  201. #endif
  202.